# DO NOT EDIT THIS FILE
#
# Please edit /boot/armbianEnv.txt to set supported parameters
#

# default values
setenv rootdev "/dev/mmcblk0p1"
setenv rootfstype "ext4"
setenv verbosity "1"
setenv emmc_fix "off"
setenv ethaddr "00:50:43:84:fb:2f"
setenv eth1addr "00:50:43:25:fb:84"
setenv eth2addr "00:50:43:84:25:2f"
setenv eth3addr "00:50:43:0d:19:18"

# fdtfile should come from compile-time u-boot patches
if test -z "${fdtfile}"; then
	setenv fdtfile "armada-388-clearfog.dtb"
fi

test -z "${boot_interface}" && setenv boot_interface "mmc"

echo "Boot script loaded from ${boot_interface}"

if load ${boot_interface} 0:1 ${loadaddr} ${prefix}armbianEnv.txt; then
	env import -t ${loadaddr} ${filesize}
fi

setenv bootargs "console=ttyS0,115200 root=${rootdev} rootwait rootfstype=${rootfstype} ubootdev=${boot_interface} scandelay loglevel=${verbosity} usb-storage.quirks=${usbstoragequirks} ${extraargs}"

load ${boot_interface} 0:1 ${fdt_addr} ${prefix}dtb/${fdtfile}
load ${boot_interface} 0:1 ${ramdisk_addr_r} ${prefix}uInitrd
load ${boot_interface} 0:1 ${kernel_addr_r} ${prefix}zImage

setenv fdt_high 0xffffffff
setenv initrd_high 0xffffffff

# eMMC fix
if test "${emmc_fix}" = "on"; then
	echo "Applying eMMC compatibility fix to the DT"
	fdt addr ${fdt_addr}
	fdt resize
	fdt rm /soc/internal-regs/sdhci@d8000/ cd-gpios
	fdt set /soc/internal-regs/sdhci@d8000/ non-removable
fi

bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr}

# Recompile with:
# mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
